package com.fit.piris.entities.message;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.tapestry5.beaneditor.NonVisual;

import com.fit.piris.entities.message.priority.MessagePriority;
import com.fit.piris.entities.user.User;

@Table(name = "messages")
@Entity
public class Message {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NonVisual
	@Column(name = "message_id")
	private Long id;
	@Column(name = "subject")
	private String subject;
	@Column(name = "body", columnDefinition = "TEXT")
	private String body;
	@ManyToOne(optional = false)
	@JoinColumn(name = "from_user_id")
	private User fromUser;
	@ManyToOne(optional = false)
	@JoinColumn(name = "to_user_id")
	private User toUser;
	@Column(name = "read_message")
	private boolean isRead;
	@ManyToOne(optional = false)
	@JoinColumn(name = "message_priority_id")
	private MessagePriority messagePriority;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public User getFromUser() {
		return fromUser;
	}

	public void setFromUser(User fromUser) {
		this.fromUser = fromUser;
	}

	public User getToUser() {
		return toUser;
	}

	public void setToUser(User toUser) {
		this.toUser = toUser;
	}

	public boolean isRead() {
		return isRead;
	}

	public void setRead(boolean isRead) {
		this.isRead = isRead;
	}

	public MessagePriority getMessagePriority() {
		return messagePriority;
	}

	public void setMessagePriority(MessagePriority messagePriority) {
		this.messagePriority = messagePriority;
	}

}
